import request from '@/utils/request'

/**
 * 获取月卡信息列表的接口
 * @param {Object} params {page,pageSize}
 * @returns
 */
export const getParkingCardListApi = (params = {}) => {
  // 配置默认值
  const defaultParams = {
    page: 1,
    pageSize: 2
  }
  const mergeParams = Object.assign({}, defaultParams, params)
  return request({
    url: '/parking/card/list',
    method: 'GET',
    params: mergeParams
  })
}
/**
 * 添加月卡的接口
 * @param {Object} data {要上传的月卡数据}
 * @returns
 */
export const addMonthCardApi = (data) => {
  return request({
    url: '/parking/card',
    method: 'POST',
    data: data
  })
}
/**
 * 获取编辑页月卡详情的接口
 * @param {String} id 要编辑的月卡的id
 * @returns
 */
export const getEditMonthCardInfoApi = (id) => {
  return request({
    url: `/parking/card/detail/${id}`,
    method: 'GET'
  })
}
/**
 * 提交编辑月卡详情的接口
 * @param {Object} data 要上传的编辑后的月卡数据
 * @returns
 */
export const putEditMonthCardInfoApi = (data) => {
  return request({
    url: `/parking/card/edit`,
    method: 'PUT',
    data: data
  })
}
/**
 * 删除月卡的接口
 * @param {String} ids 要删除的月卡id,批量删除时，id用逗号隔开
 * @returns
 */
export const deleteMonthCardInfoApi = (ids) => {
  if (!ids) return
  return request({
    url: `/parking/card/${ids}`,
    method: 'DELETE'
  })
}
